<?php
namespace backend\controller;
use backend\controller\BackendBaseController;
use jimu\Request;
use common\model\config_model;

class ConfigController extends BackendBaseController
{
    public function __construct()
    {
        parent::__construct();
    }

    public function websiteAction()
    {
        $config = new config_model();
        if(is_post()){
            try{
                $params = Request::post();
                if(!isset($params['web_site_visit']) || empty($params['web_site_visit'])){
                    $params['web_site_visit'] = 0;
                }
                $config->saveConfigs($params);
                ajaxReturn(['code'=>1,'msg'=>'success']);
            }catch(\Exception $e){
                ajaxReturn(['code'=>$e->getCode(),'msg'=>$e->getMessage()]);
            }
        }
        $list = $config->getAllConfig();
        $this->assign('configs',$list);

        $this->display();
    }
}